<?php
//提示信息
class lib_message{
	private static $message;
	
	//提示信息赋值
    public static function message($value,$dontCover = false){
        $_session = session::instance();
        $message = empty(self::$message)?$_session->get('message'):self::$message;
        if ($dontCover && !empty($message))
        	self::$message = $message.$value.'<br />';
        else
        	self::$message = $value.'<br />';
        $_session->set('message',self::$message);
    }
    
    //获取提示信息
    public static function get(){
    	$_session = session::instance();
        $message = empty(self::$message)?$_session->get('message'):self::$message;
    	return (string)$message;
    }
    
    //提示信息提示
    public static function messageShow($template = null){
    	$_session = session::instance();
        $message = empty(self::$message)?$_session->get('message'):self::$message;
        $_session->delete('message');
        if (empty($message)){
        	$html = '<p style="display:none"></p>';
            return $html;
        }else{
        	if (Kohana::find_file('views/message', $template)){
        		$html = View::factory('message/'.$template)->set('message',$message);
        	}else{
        		$html = '<div style="width:400px;border:3px solid #355568;"><div style="width:390px;border-bottom:1px dotted gray;padding:5px;font-size:14px;font-family:微软雅黑"><span style="font-weight:bold;color:red;">INFORMATION</span>系统信息</div><div style="width:390px;padding:10px;text-align:center;"><div style="margin:0px auto;width:300px;">'.$message.'</div></div></div>';
        	}
            return $html;
        }
    }
}